public class TestDemo2 {
    public static void swap(int[] arr)
    {
        int temp = arr[0];
        arr[0] = arr[1];
        arr[1] = temp;
    }

    public static void main(String[] args) {
        int[] arr = {10,20};
        System.out.println("交换前: " + arr[0] + " " + arr[1]);
        swap(arr);
        System.out.println("交换后: " + arr[0] + " " + arr[1]);
    }
}
